﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="SupplierGroup.aspx.cs" Inherits="DevExpressWebApplication1.Module.CM.SupplierGroup" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
      <script type="text/javascript">
          function openAdd() {
              hdfSupGroupID.Set("SupGroupId", -1);
              ClearData();
              popupAddEdit.Show();
          }
          function EditSupGroup() {
              // var key = gvCustomer.GetRowKey(gvCustomer.GetFocusedRowIndex());
              var index = gvSupGroup.GetFocusedRowIndex();
              cbAddEdit.PerformCallback('Edit;' + index);
              popupAddEdit.Show();
          }
          function ClearData() {
              txtSupGroup.SetValue('');
              txtDescription.SetValue('');
          }

    </script>
    <div class="span10">
        <dx:ASPxButton runat="server" ID="btnAdd" Text="Add" Theme="DevEx" UseSubmitBehavior="False" AutoPostBack="False">
            <ClientSideEvents Click="function(s,e){openAdd()}" />
        </dx:ASPxButton>
    </div>
    <div class="span10">
        <asp:SqlDataSource ID="dsSupGroup" runat="server" ConnectionString="<%$ ConnectionStrings:PPL_ERPConnectionString %>" SelectCommand="sp_Group_GetByType" SelectCommandType="StoredProcedure">
            <SelectParameters>
                <asp:Parameter DefaultValue="0" Name="Type" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
 
        <dx:ASPxGridView ID="gvSupGroup" ClientInstanceName="gvSupGroup" OnCustomCallback="gvSupGroup_CustomCallback"  ClientIDMode="Static"
            Width="100%" runat="server" AutoGenerateColumns="False" DataSourceID="dsSupGroup" KeyFieldName="group_id" Theme="DevEx">
            <Columns>
                <dx:GridViewDataTextColumn FieldName="group_id" VisibleIndex="0" Visible="false" ReadOnly="True">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="group_name" VisibleIndex="1">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="type" VisibleIndex="2" Visible="false" >
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="description" VisibleIndex="3">
                </dx:GridViewDataTextColumn>
            </Columns>
            <ClientSideEvents RowDblClick="function(s,e){ EditSupGroup() }" />
            <SettingsBehavior AllowFocusedRow="True" />
        </dx:ASPxGridView>
    </div>
     <dx:ASPxPopupControl ID="popupAddEdit" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
        CssPostfix="Aqua" SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" ClientInstanceName="popupAddEdit"
        HeaderText="Quản lý nhóm nhà cung cấp" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Theme="DevEx"
        EnableClientSideAPI="True" Width="650px" Height="200px">
        <%-- PopupElementID="divPotential" --%>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl6" runat="server" SupportsDisabledAttribute="True">
                <div style="width: 100%">
                    <dx:ASPxCallbackPanel ID="cbAddEdit" ClientInstanceName="cbAddEdit" OnCallback="cbAddEdit_Callback" runat="server" Width="100%">
                        <PanelCollection>
                            <dx:PanelContent>
                                <dx:ASPxHiddenField ID="hdfSupGroupID" ClientInstanceName="hdfSupGroupID" runat="server" />
                                <table width="100%">
                                    <tr>
                                        <td style="width: 20%">Nhóm NCC
                                        </td>
                                        <td style="width: 30%">
                                            <dx:ASPxTextBox ID="txtSupGroup" ClientInstanceName="txtSupGroup" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                        <td style="width: 20%">Chi tiết 
                                        </td>
                                        <td style="width: 30%">
                                            <dx:ASPxTextBox ID="txtDescription" ClientInstanceName="txtDescription"  runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                            <dx:ASPxButton ID="ASPxButton1" runat="server" Text="Cập nhật" UseSubmitBehavior="False" AutoPostBack="False">
                                                <ClientSideEvents Click="function(s,e){ gvSupGroup.PerformCallback('Add'); }" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
</asp:Content>
